﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Public;

namespace QLNhanKhau
{
    public partial class frmChiTietKhaiSinh : Form
    {
        public frmChiTietKhaiSinh()
        {
            InitializeComponent();
        }
        int MaNK;
        public frmChiTietKhaiSinh(int MaNK)
        {
            InitializeComponent();
            this.MaNK = MaNK;
        }

        private void frmChiTietKhaiSinh_Load(object sender, EventArgs e)
        {
            NhanKhauPublic nk = NhanKhauBLL.LoadNhanKhauByMaNK(MaNK);
            ThietLapPublic tl = ThietLapBLL.LoadThietLapByMaNK(MaNK);
            txtHoTen.Text = nk.HoTen;
            if (nk.GioiTinh == true)
                sbtGioiTinh.Value = true;
            else
                sbtGioiTinh.Value = false;
            txtNoiSinh.Text = TinhBLL.LoadTinhByMaT((int)nk.NoiSinh);
            dateNgaySinh.Value = (DateTime)nk.NgaySinh;
            txtDanToc.Text = DanTocBLL.LoadDanTocByMaDT(nk.MaDT).TenDanToc;
            txtQuocTich.Text = QuocTichBLL.LoadQuocTichByMaQT(nk.MaQT).TenQuocTich;
           
            
            KhaiSinhPublic ks = KhaiSinhBLL.LoadKhaiSinhByMaKS(nk.MaKS, tl.TenServer, tl.TenData);
            txtMaKS.Text = nk.MaKS.ToString();
            txtQueQuan.Text = nk.QueQuan;
            txtSoKhaiSinh.Text = ks.SoKhaiSinh.ToString();
            txtHoTenCha.Text = NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKC).HoTen;
            txtHoTenMe.Text = NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKM).HoTen;
            txtDanTocCha.Text = DanTocBLL.LoadDanTocByMaDT(NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKC).MaDT).TenDanToc;
            txtDanTocMe.Text = DanTocBLL.LoadDanTocByMaDT(NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKM).MaDT).TenDanToc;
            txtQuocTichCha.Text = QuocTichBLL.LoadQuocTichByMaQT(NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKC).MaQT).TenQuocTich;
            txtQuocTichMe.Text = QuocTichBLL.LoadQuocTichByMaQT(NhanKhauBLL.LoadNhanKhauByMaNK(ks.MaNKM).MaQT).TenQuocTich;
            //txtQuanHeKS.Text = QuanHeBLL.LoadQuanHeByMaQH(ks.MaQH).TenQuanHe;
            txtCanBoHoTich.Text = NguoiDungBLL.LoadNguoiDungByMaND(ks.CanBoHoTich).HoTen;
            
            txtNguoiDangki.Text = ks.NguoiDangKi;
            txtNguoiCap.Text = NguoiDungBLL.LoadNguoiDungByMaND(ks.NguoiCap).HoTen;
            dateNgayCap.Value = (DateTime)ks.NgayCap;
            txtChucVu.Text = ChucVuBLL.LoadChucVuByMaCV(NguoiDungBLL.LoadNguoiDungByMaND(ks.NguoiCap).MaCV).TenChucVu;
            dateNgayCap.Value = ks.NgayCap.Value;
            txtQuanHeKS.Text = QuanHeBLL.LoadQuanHeByMaQH(((byte)ks.MaQH)).TenQuanHe;
            txtNoiCap.Text = ThietLapBLL.LoadDiaChiByMaDiaChi(ks.NoiCap);
            //cmbCanBoDangKiKS.Text = NguoiDungBLL.LoadNguoiDungByMaND(ks.CanBoDangKi).HoTen;
            //cmbNguoiNhanKS.Text = NguoiDungBLL.LoadNguoiDungByMaND(ks.NguoiNhan).HoTen;
            //txtChucVuNguoiCapKS.Text = ChucVuBLL.LoadChucVuByMaCV(NguoiDungBLL.LoadNguoiDungByMaND(ks.NguoiNhan).MaCV).TenChucVu;
            //dateNgayNhapKS.Value = (DateTime)ks.NgayNhap;
        }

        private void btnXong_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }


}
